package com.graduation.cdm.funactivity.util;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * Created by cdm on 2017/2/28.
 */

public class TestPhoneEmail {

    //手机号码验证
    public static boolean isMobileId(String mobile){
        Pattern pattern = Pattern.compile("^((13[0-9])|(15[^4,\\D])|(18[0,5-9]))\\d{8}$");
        Matcher matcher = pattern.matcher(mobile);
        return matcher.matches();
    }

    //邮箱验证
    public static boolean isEmailId(String email){
        Pattern pattern = Pattern.compile("^([a-zA-Z0-9_\\-\\.]+)@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.)|(([a-zA-Z0-9\\-]+\\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$");
        Matcher matcher = pattern.matcher(email);
        return matcher.matches();
    }
}
